from selenium import webdriver
import pytest
import openpyxl
from jiedian.Base import Base
@pytest.fixture
def driver():
    driver=webdriver.Edge()
    driver.maximize_window()
    yield driver
def test_login(driver):
    play=openpyxl.load_workbook("jiuxian.xlsx")
    exal=play["Sheet1"]
    base=Base(driver)
    driver=None
    for item in exal.iter_rows(min_row=2,values_only=True):
        action=item[2]#操作类型
        pame={}
        if action =="goto":
            pame["url"]=item[4]
        if action in ["click","fill","gettext"]:
            type=item[3]
            value=item[4]
            pame["locator"]=[type,value]
            if action =="fill":
                pame["word"]=item[5]
        elif action == "sleep_time":
            pame["wait_time"]=item[5]
        method=getattr(base,action)
        if action =="gettext":
            text=method(**pame)
            assert text== item[5]
            print(text)
        method(**pame)